package org.idea.qiyu.framework.datasource.properties;

import org.idea.qiyu.framework.datasource.config.DatasourceConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 多数据源配置管理
 *
 * @Author linhao
 * @Date created in 11:29 上午 2021/5/25
 */
@ConfigurationProperties(prefix = "multi.datasource")
public class MultiDataSourceProperties {

    private String defaultDatasource;

    private ConcurrentHashMap<String, DatasourceConfig> datasources = new ConcurrentHashMap<String, DatasourceConfig>();

    public DatasourceConfig getDatasourceByName(String datasourceName) {
        return datasources.get(datasourceName);
    }

    public String getDefaultDatasource() {
        return defaultDatasource;
    }

    public void setDefaultDatasource(String defaultDatasource) {
        this.defaultDatasource = defaultDatasource;
    }

    public ConcurrentHashMap<String, DatasourceConfig> getDatasources() {
        return datasources;
    }

    public void setDatasources(ConcurrentHashMap<String, DatasourceConfig> datasources) {
        this.datasources = datasources;
    }

}
